/**
 * 
 */
package t4j.concurrency.deadlock;


//筷子
public class Chopstick {

	private boolean taken = false;

	public synchronized void take() throws InterruptedException {
		while (taken)
			wait();//被拿去了就等待阻塞
		taken = true;
	}
	
	public synchronized void drop(){
		taken = false;
		notifyAll();//唤醒被wait()阻塞的所有任务
		
	}
}
